package a2;

import java.awt.Color;
import java.awt.Graphics2D;

/**
 * Title: Rectangle class for CSIS 235 Assignment #2
 * Description: CS 235 Assignment #2 - Rectangle
 *              Rectangle class is a server class
 * @author Anthony Varghese
 * @email  anthony.varghese@uwrf.edu
 * @author 
 * @email  
 * @author 
 * @email  
 * @author 
 * @email  
 * @date   
 */

public class Rectangle {
	private int x1, y1;
	private int x2, y2;
	private Color color;
	
	public Rectangle() {
	}

	public Rectangle(int x2_in, int y2_in) {
		x2 = x2_in;
		y2 = y2_in;
	}

	public Rectangle(int x1_in, int y1_in, int x2_in, int y2_in) {
		x1 = x1_in;
		y1 = y1_in;
		x2 = x2_in;
		y2 = y2_in;
	}

	public Rectangle(int x1_in, int y1_in, int x2_in, int y2_in, Color c_in) {
		x1 = x1_in;
		y1 = y1_in;
		x2 = x2_in;
		y2 = y2_in;
		color = c_in;
	}

	public Rectangle(Rectangle r) {
		x1 = r.x1;
		y1 = r.y1;
		x2 = r.x2;
		y2 = r.y2;		
	}

	public void draw(Graphics2D g2d){
		int width = x2-x1;
		int height = y2-y1;
		if (color == null)
			g2d.drawRect(x1, y1, width, height);
		else{
			g2d.setColor( color );
			g2d.fillRect( x1, y1, width, height);
		}
	}
}
